#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>

#define RCVBUFSIZE 32

int main(){

  int sock;
  struct sockaddr_in echoServAddr;
  unsigned short echoServPort;
  char *servIP;
  char *echoString;
  char echoBuffer[RCVBUFSIZE];
  unsigned int echoStringLen;
  int bytesRcvd, totalBytesRcvd;

  if ((sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0){
    printf("Socket Error\n");
    exit(1);
  }

  servIP = (char*)malloc(sizeof(char)*15);
  strcpy(servIP, "127.0.0.1");
  echoServPort = 10212;

  memset(&echoServAddr, 0, sizeof(echoServAddr));
  echoServAddr.sin_family      = AF_INET;
  echoServAddr.sin_addr.s_addr = inet_addr(servIP);
  echoServAddr.sin_port        = htons(echoServPort);

  if (connect(sock, (struct sockaddr *) &echoServAddr, sizeof(echoServAddr)) < 0){
    printf("Connect Error\n");
    exit(1);
  }

  printf("Connect Successful!\n");
  free(servIP);

}
